package com.galacticconversion.command;

import com.galacticconversion.model.DataStorage;
import com.galacticconversion.util.RomanNumberUtil;

/**
 * 处理查询数值命令 (如 "how much is pish tegj glob glob ?")
 */
public class GalacticValueCommand implements Command {
    private final DataStorage dataStorage;

    public GalacticValueCommand(DataStorage dataStorage) {
        this.dataStorage = dataStorage;
    }

    @Override
    public void execute(String input) {
        String galacticUnits = input.substring("how much is ".length(), input.length() - 1).trim();
        String roman = RomanNumberUtil.convertGalacticToRoman(galacticUnits, dataStorage);
        int value = RomanNumberUtil.romanToDecimal(roman);

        if (value > 0) {
            System.out.println(galacticUnits + " is " + value);
        } else {
            System.out.println("I have no idea what you are talking about");
        }
    }
}